{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# INVALID_GRAPH_NODE_RETURN_VALUE\n",
    "\n",
    "A LangGraph [`StateGraph`](https://langchain-ai.github.io/langgraphjs/reference/classes/langgraph.StateGraph.html)\n",
    "received a non-object return type from a node. Here's an example:\n",
    "\n",
    "```ts\n",
    "const StateAnnotation = Annotation.Root({\n",
    "  someKey: Annotation<string>,\n",
    "});\n",
    "\n",
    "const graph = new StateGraph(StateAnnotation)\n",
    "  .addNode(\"badNode\", async (state) => {\n",
    "    // Should return an empty object, one with a value for \"someKey\", or undefined\n",
    "    return [\"whoops!\"];\n",
    "  })\n",
    "  ...\n",
    "  .compile();\n",
    "```\n",
    "\n",
    "Invoking the above graph will result in an error like this:\n",
    "\n",
    "```ts\n",
    "await graph.invoke({ someKey: \"someval\" });\n",
    "```\n",
    "\n",
    "```\n",
    "InvalidUpdateError: Expected node \"badNode\" to return an object, received number\n",
    "\n",
    "Troubleshooting URL: https://js.langchain.com/troubleshooting/errors/INVALID_GRAPH_NODE_RETURN_VALUE\n",
    "```\n",
    "\n",
    "Nodes in your graph must return an object containing one or more keys defined in your state.\n",
    "\n",
    "## Troubleshooting\n",
    "\n",
    "The following may help resolve this error:\n",
    "\n",
    "- If you have complex logic in your node, make sure all code paths return an appropriate object for your defined state.\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
